<?php
//
// phpmailer.mailer.php "PhpMailer" mailer class implementation
//

require_once("class.phpmailer.php");
require_once("class.smtp.php");

class SV_Mailer_phpmailer implements iSV_Mailer{
	protected
		$phpmailer;	
//
//	Constructor
//
//	$args - list of  ('key' => 'value') pairs
//	
	public function __construct($args){		
		$use = "smtp"; $smtpHost = ""; $smtpPort =25; $smtpAuth = false; $userName =""; $pass=""; $charset = "utf-8"; $contentType = "text/plain";
		$debug = false;
		extract($args);
		
		$phpmailer = new PHPMailer();
		$phpmailer->CharSet = $charset;
		$phpmailer->ContentType = $contentType;
		$phpmailer->Mailer = $use;
		$phpmailer->Host = $smtpHost;
		$phpmailer->Port = $smtpPort;
		$phpmailer->SMTPAuth = $smtpAuth;
		$phpmailer->Username = $userName;
		$phpmailer->Password = $pass;			
		$phpmailer->SMTPDebug = $debug;
		$this->phpmailer = $phpmailer;
		
	} /* __construct */
	
	public function &getMailer() { return $this->phpmailer; }
	
	public function AddCustomHeader($str){
		$this->phpmailer->AddCustomHeader($str);
	} /* AddCustomHeader */
	
	public function AddAddress($to, $toname){
		$this->phpmailer->AddAddress($to, $toname);
	} /* AddAddress */
	
	public function SetFrom($from, $fromname){
		$this->phpmailer->From = $from;
		$this->phpmailer->FromName = $fromname;		
	} /* SetFrom */
	
	public function SetSubject($subj){
		$this->phpmailer->Subject = $subj;		
	} /* SetSubject */
	
	public function SetBody($body){
		$this->phpmailer->Body = $body;
	} /* SetBody */
	
	public function Send(){
		return $this->phpmailer->Send();
	}
	
}

?>
